/*
 * fml_flash.h
 *
 *  Created on: 2025年4月9日
 *      Author: 22332
 */

#ifndef FML_FLASH_H_
#define FML_FLASH_H_
#include <stdint.h>
#include <stdbool.h>

#define B_part_address 		0x00024000

#define A_vendor_address 	0x10006000

#define B_vendor_address 	0x10007000

#define D_FLASH_START_ADDRESS 	0x10000000

typedef struct VENDOR_DATA
{//新增结构体内容时，时刻关注字节对齐问题以及写flash大小必须为8的倍数！！！！！否则写flash出错!!
	uint32_t crc32;
    uint8_t mcu_upgrade_flag;		///< MCU的升级标志
    uint8_t screen_brightness;		///< 屏幕亮度

    uint8_t PN_VERSION0;
    uint8_t PN_VERSION1;
    uint8_t PN_VERSION2;
    uint8_t PN_VERSION3;
    uint8_t PN_VERSION4;
    uint8_t PN_VERSION5;

    uint8_t HARDWARE_VERSION0;
    uint8_t HARDWARE_VERSION1;
    uint8_t HARDWARE_VERSION2;
    uint8_t HARDWARE_VERSION3;
    uint8_t HARDWARE_VERSION4;
    uint8_t HARDWARE_VERSION5;

    uint8_t SOFTWARE_VERSION0;
    uint8_t SOFTWARE_VERSION1;
    uint8_t SOFTWARE_VERSION2;
    uint8_t SOFTWARE_VERSION3;
    uint8_t SOFTWARE_VERSION4;
    uint8_t SOFTWARE_VERSION5;

    uint8_t TFT_SW_VERSION0;
    uint8_t TFT_SW_VERSION1;
    uint8_t TFT_SW_VERSION2;
    uint8_t TFT_SW_VERSION3;
    uint8_t TFT_SW_VERSION4;

    uint8_t TFT_HW_VERSION0;
	uint8_t TFT_HW_VERSION1;
	uint8_t TFT_HW_VERSION2;
	uint8_t TFT_HW_VERSION3;
	uint8_t TFT_HW_VERSION4;
	
	uint8_t DH_SW_VERSION0;
    uint8_t DH_SW_VERSION1;
    uint8_t DH_SW_VERSION2;
    uint8_t DH_SW_VERSION3;
    uint8_t DH_SW_VERSION4;

    uint8_t DH_HW_VERSION0;
	uint8_t DH_HW_VERSION1;
	uint8_t DH_HW_VERSION2;
	uint8_t DH_HW_VERSION3;
	uint8_t DH_HW_VERSION4;
    uint8_t host_ack_upgrade;

    uint8_t DiagStatus1;
    uint8_t DiagStatus2;//47

    uint8_t pDiagArray[10];
    uint8_t reserved[199];//补齐8的整数倍,目前总共256个字节
}ST_VENDOR_DATA;
extern void vendor_data_save(void);
extern bool vendor_data_load(void);
extern void vendor_factory_set(void);

extern void fml_flash_init(void);
extern void fml_flash_write_upgrade(uint32_t address, uint8_t *buf,int length);//write 2048 byte
extern void fml_flash_read(uint32_t address, uint8_t *buf,uint8_t length);

#endif /* FML_FLASH_H_ */
